#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int a[] = {5,3,6,2,1,4,8,7};
void bubble_sort(int a[],int len){
	for(int i = 0; i < len-1 ;i++){
		for(int j = 1 ; j < len;j++){
			if(a[j-1]>a[j]){
				int t = a[j-1];
				a[j-1] = a[j];
				a[j] = t;
			}
		}
	}
}
int main(){
	int n = sizeof(a) / sizeof(a[0]);
	printf("冒泡排序前数组为:");
	for(int i = 0 ; i < n ; i++){
		printf("%d ",a[i]);
	}
	printf("\n冒泡排序后数组为:");
	bubble_sort(a,n);
	for(int i = 0 ; i < n ; i++){
		printf("%d ",a[i]);
	}
	
	
	return 0;
}
